home *** CD-ROM | disk | FTP | other *** search
- Path: news.sprintlink.net!datalytics!usenet
- From: Dellis Hines <dellish@datalytics.com>
- Newsgroups: comp.lang.c++
- Subject: Re: C++ guru sought ...
- Date: Thu, 11 Apr 1996 16:52:26 -0400
- Organization: Datalytics, Inc
- Message-ID: <316D710A.4B6C@datalytics.com>
- References: <316CB5B5.41C6@cs.york.ac.uk>
- NNTP-Posting-Host: 204.62.224.100
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 3.0B2 (WinNT; I)
-
- John Kennedy wrote:
- >
- > Hi there,
- >
- > I have an interesting C++ problem that I was wondering if any guru out
- > there knows the answer to....
- >
- > I am trying to create a template class that saves or reads data to/from
- > a file. This is not a problem for numeric data as fstream can cope with
- > this no problem. The problem I have is that when the template type is a
- > string I have to create the space to store the data in. The only way I
- > can see of doing this is to use a case statement in the template
- > function but this is then removing all purpose of creating a template in
- > the first place.
- >
- > Does anyone know a way around this problem ?
- >
- > John Kennedy
- >
- > johnk@cs.york.ac.uk
-
- Try reading a book called 'Advanced C++ Programming Styles and Idioms' by James Coplien of
- Bell Labs. In it he elucidates a number of programming styles to get around problems
- like this, which just about require a 'virtual constructor'. I have successfully used one
- of his idioms (the 'envelope and letter' idiom) to get around just such a problem on several
- projects.
-
- This is a very good book that presents solutions to a segment of the language rarely tackled
- by many book writers, that of introducing runtime flexibility without sacrificing type
- safety and maintainability. I can recommend it without hesitation.
-
- Regards,
- Dellis Hines
- dellish@datalytics.com
-